const { db } = require("../../db/db2");
const moment = require("moment");

async function SaveUserInfo(req, res) {
  const {
    UserName,
    HeaderImg,
    SelfDescription,
    ActionWorkTime,
    WorkName,
    Company,
    IntertesTab,
    MyHomeUrl,
    WorkId,
  } = req.body;
  console.log("req.body", req.body);

  const UserId = Number(req.params.username);

  const update_sql = `UPDATE User SET UserName=?,HeaderImg=?,SelfDescription=?,ActionWorkTime=?,WorkName=?,Company=?,IntertesTab=?,MyHomeUrl=?,WorkId=? WHERE UserId=?`;
  db.query(
    update_sql,
    [
      UserName,
      HeaderImg,
      SelfDescription,
      ActionWorkTime,
      WorkName,
      Company,
      IntertesTab,
      MyHomeUrl,
      WorkId,
      UserId,
    ],
    (err, results) => {
      if (err) {
        res.send({
          Message: err,
          status: 1,
        });
        return
      }

      res.send({
        status: 0,
      });
    }
  );
}

module.exports = { SaveUserInfo };
